package com.bankcard.core;

import com.bankcard.bininfo.BinInfoRepository;
import com.bankcard.bininfo.loader.BinInfoLoader;
import com.bankcard.bininfo.model.BinInfo;
import com.bankcard.bininfo.model.Countries;
import com.bankcard.bininfo.model.IssuerCards;
import com.bankcard.bininfo.model.Issuers;

import java.io.InputStream;
import java.util.List;
import java.util.function.Supplier;

/**
 * Configuration class for the bankcard utility library.
 *
 * <p>This class provides static methods to configure and load various components
 * of the bankcard utility library, including BIN (Bank Identification Number) information,
 * country data, issuer information, and issuer card details.</p>
 *
 * <p>It serves as a centralized point for initializing and updating the data
 * used by the library. The class cannot be instantiated and all methods are static.</p>
 *
 * <p>Usage example:</p>
 * <pre>{@code
 * // Load initial BIN information from a JSON file
 * BankConfig.loadInitialBinInfo(true, "/custom/bin_info.json");
 *
 * // Load country information
 * String countryJson = "[{\"isoCountryName\":\"United States\",\"isoCountryCodeA2\":\"US\",\"isoCountryCodeA3\":\"USA\",\"isoCountryCurrency\":\"USD\"}]";
 * BankConfig.loadCountries(countryJson);
 *
 * // Update quick match data for BIN ranges
 * String quickMatchJson = "{\"622126-622925\":\"BOA_VISA\",\"60400100-60420099\":\"CHASE_MASTER\"}";
 * BankConfig.updateQuickMatchData(quickMatchJson);
 * }</pre>
 *
 * @see BinInfoLoader
 * @see Countries
 * @see Issuers
 * @see IssuerCards
 * @see BinInfoRepository
 */
public class BankConfig {
    private BankConfig() {
        // Private constructor to prevent instantiation
    }

    public static void loadInitialBinInfo(boolean useJson, String binInfoFilePath) {
        BinInfoLoader.loadInitialBinInfo(useJson, binInfoFilePath);
    }

    public static void loadBinInfo(Supplier<List<BinInfo>> binInfoSupplier) {
        BinInfoLoader.loadBinInfo(binInfoSupplier);
    }

    public static void loadIncrementalBinInfo(InputStream inputStream, boolean isJson) {
        BinInfoLoader.loadIncrementalBinInfo(inputStream, isJson);
    }

    public static void loadIncrementalBinInfo(String data) {
        BinInfoLoader.loadIncrementalBinInfo(data);
    }

    public static void loadCountries(String json) {
        Countries.loadCountries(json);
    }

    public static void loadIssuers(String json) {
        Issuers.loadIssuers(json);
    }

    public static void loadIssuerCards(String config) {
        IssuerCards.loadIssuerCards(config);
    }

    public static void updateQuickMatchData(String jsonString) {
        BinInfoRepository.updateQuickMatchData(jsonString);
    }
}
